package com.zdd.ehe.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdd.ehe.entity.ProvinceProduceData;
import com.zdd.ehe.entity.Role;
import com.zdd.ehe.mapper.ProvinceProduceDataMapper;
import com.zdd.ehe.service.IProvinceProduceDataService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ZhuiZhu
 * @since 2023-03-24
 */
@Service
public class ProvinceProduceDataServiceImpl extends ServiceImpl<ProvinceProduceDataMapper, ProvinceProduceData> implements IProvinceProduceDataService {
    @Resource
    private ProvinceProduceDataMapper provinceProduceDataMapper;

    /**
     * 分页查询各省份作物产量数据列表
     *
     * @param page
     * @return
     */
    @Override
    public Page<ProvinceProduceData> getAllProvinceProduceByPage(Page<ProvinceProduceData> page) {
        Page<ProvinceProduceData> pagex = provinceProduceDataMapper.getAllProvinceProduceByPage(page);
        return pagex;
    }

    /**
     * 查询各种类各省份的产量数据
     *
     * @param type
     * @return
     */
    @Override
    public List<ProvinceProduceData> getProvinceProduceByType(String type) {
        QueryWrapper<ProvinceProduceData> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("type",type);
        List<ProvinceProduceData> provinceProduceDataList = provinceProduceDataMapper.selectList(queryWrapper);
        return provinceProduceDataList;
    }


    @Override
    public int addProvinceProduceData(ProvinceProduceData provinceProduceData) {
        return provinceProduceDataMapper.insert(provinceProduceData);
    }

    @Override
    public int updateProvinceProduceDataById(ProvinceProduceData provinceProduceData) {
        return provinceProduceDataMapper.updateById(provinceProduceData);
    }
}
